package edu.uwm.RobberKnight.View;

import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;

import edu.uwm.RobberKnight.Model.TileType;

/*
 * Cache for all the image resources.
 */
public class Resources {
	
	//tile faces
	private static Image castle_plains;
	private static Image castle_forest;
	private static Image plains;
	private static Image lake;
	private static Image mountain;
	private static Image village_plains;
	private static Image village_forest;
	private static Image town_plains;
	private static Image town_forest;
	
	//other
	private static Image add;
	private static Image fullscreen;
	private static Image selection;
	private static Image title;
	private static Image gamePlay;
	private static Image landscape;
	private static Image initialPosessions;
	private static Image tilesTypePic;
	private static Image playingKnightPic;
	private static Image scoringPic;
	private static Image regularTurnsPic;
	
	//knights
	private static Image knight_red;
	private static Image knight_blue;
	private static Image knight_green;
	private static Image knight_yellow;
	
	//tile backs
	private static Image shield_red_a;
	private static Image shield_red_b;
	private static Image shield_red_c;
	private static Image shield_red_d;
	private static Image shield_red_e;
	private static Image shield_blue_a;
	private static Image shield_blue_b;
	private static Image shield_blue_c;
	private static Image shield_blue_d;
	private static Image shield_blue_e;
	private static Image shield_green_a;
	private static Image shield_green_b;
	private static Image shield_green_c;
	private static Image shield_green_d;
	private static Image shield_green_e;
	private static Image shield_yellow_a;
	private static Image shield_yellow_b;
	private static Image shield_yellow_c;
	private static Image shield_yellow_d;
	private static Image shield_yellow_e;
	
	/*
	 * Load all the image resources.
	 */
	public static void loadResources() {
		castle_plains = Toolkit.getDefaultToolkit().getImage("res/castle_plains.png");
		castle_forest = Toolkit.getDefaultToolkit().getImage("res/castle_forest.png");
		plains = Toolkit.getDefaultToolkit().getImage("res/plains.png");
		lake = Toolkit.getDefaultToolkit().getImage("res/lake.png");
		village_plains = Toolkit.getDefaultToolkit().getImage("res/village_plains.png");
		village_forest = Toolkit.getDefaultToolkit().getImage("res/village_forest.png");
		town_plains = Toolkit.getDefaultToolkit().getImage("res/town_plains.png");
		town_forest = Toolkit.getDefaultToolkit().getImage("res/town_forest.png");
		mountain = Toolkit.getDefaultToolkit().getImage("res/mountains.png");
	
		shield_red_a = Toolkit.getDefaultToolkit().getImage("res/shield_red_a.png");
		shield_red_b = Toolkit.getDefaultToolkit().getImage("res/shield_red_b.png");
		shield_red_c = Toolkit.getDefaultToolkit().getImage("res/shield_red_c.png");
		shield_red_d = Toolkit.getDefaultToolkit().getImage("res/shield_red_d.png");
		shield_red_e = Toolkit.getDefaultToolkit().getImage("res/shield_red_e.png");
		
		shield_blue_a = Toolkit.getDefaultToolkit().getImage("res/shield_blue_a.png");
		shield_blue_b = Toolkit.getDefaultToolkit().getImage("res/shield_blue_b.png");
		shield_blue_c = Toolkit.getDefaultToolkit().getImage("res/shield_blue_c.png");
		shield_blue_d = Toolkit.getDefaultToolkit().getImage("res/shield_blue_d.png");
		shield_blue_e = Toolkit.getDefaultToolkit().getImage("res/shield_blue_e.png");
		
		shield_green_a = Toolkit.getDefaultToolkit().getImage("res/shield_green_a.png");
		shield_green_b = Toolkit.getDefaultToolkit().getImage("res/shield_green_b.png");
		shield_green_c = Toolkit.getDefaultToolkit().getImage("res/shield_green_c.png");
		shield_green_d = Toolkit.getDefaultToolkit().getImage("res/shield_green_d.png");
		shield_green_e = Toolkit.getDefaultToolkit().getImage("res/shield_green_e.png");
		
		shield_yellow_a = Toolkit.getDefaultToolkit().getImage("res/shield_yellow_a.png");
		shield_yellow_b = Toolkit.getDefaultToolkit().getImage("res/shield_yellow_b.png");
		shield_yellow_c = Toolkit.getDefaultToolkit().getImage("res/shield_yellow_c.png");
		shield_yellow_d = Toolkit.getDefaultToolkit().getImage("res/shield_yellow_d.png");
		shield_yellow_e = Toolkit.getDefaultToolkit().getImage("res/shield_yellow_e.png");
		
		add = Toolkit.getDefaultToolkit().getImage("res/add.png");
		fullscreen = Toolkit.getDefaultToolkit().getImage("res/fullscreen.png");
		selection = Toolkit.getDefaultToolkit().getImage("res/selection.png");
		title = Toolkit.getDefaultToolkit().getImage("res/title.png");
		gamePlay = Toolkit.getDefaultToolkit().getImage("res/gamePlay.png");
		landscape = Toolkit.getDefaultToolkit().getImage("res/landscape.png");
		initialPosessions = Toolkit.getDefaultToolkit().getImage("res/initialPosessions.png");
		tilesTypePic= Toolkit.getDefaultToolkit().getImage("res/tilesTypePic.png");
		playingKnightPic = Toolkit.getDefaultToolkit().getImage("res/playingKnightPic.png");
		scoringPic = Toolkit.getDefaultToolkit().getImage("res/scoringPic.png");
		regularTurnsPic = Toolkit.getDefaultToolkit().getImage("res/regularTurnsPic.png");
		
		
		knight_red = Toolkit.getDefaultToolkit().getImage("res/knight_red.png");
		knight_blue = Toolkit.getDefaultToolkit().getImage("res/knight_blue.png");
		knight_green = Toolkit.getDefaultToolkit().getImage("res/knight_green.png");
		knight_yellow = Toolkit.getDefaultToolkit().getImage("res/knight_yellow.png");
	}
	 
	public static Image getTileFaceImage(TileType type) {
		switch(type) {
		case CASTLE_PLAIN:
			return castle_plains;
		case CASTLE_FOREST:
			return castle_forest;
		case PLAIN:
			return plains;
		case MOUNTAIN:
			return mountain;
		case LAKE:
			return lake;
		case TOWN_FOREST:
			return town_forest;
		case TOWN_PLAIN:
			return town_plains;
		case VILLAGE_FOREST:
			return village_forest;
		case VILLAGE_PLAIN:
			return village_plains;
		default:
			return null;
		}
	}
	
	public static Image getTileBackImage(Color color, char letter) {
		if(color.equals(Color.RED)) {
			switch(letter) {
				case 'A':
					return shield_red_a;
				case 'B':
					return shield_red_b;
				case 'C':
					return shield_red_c;
				case 'D':
					return shield_red_d;
				case 'E':
					return shield_red_e;
			}
		} else if(color.equals(Color.BLUE)) {
			switch(letter) {
				case 'A':
					return shield_blue_a;
				case 'B':
					return shield_blue_b;
				case 'C':
					return shield_blue_c;
				case 'D':
					return shield_blue_d;
				case 'E':
					return shield_blue_e;
			}
		} else if(color.equals(Color.GREEN)) {
			switch(letter) {
				case 'A':
					return shield_green_a;
				case 'B':
					return shield_green_b;
				case 'C':
					return shield_green_c;
				case 'D':
					return shield_green_d;
				case 'E':
					return shield_green_e;
			}
		} else if(color.equals(Color.YELLOW)) {
			switch(letter) {
				case 'A':
					return shield_yellow_a;
				case 'B':
					return shield_yellow_b;
				case 'C':
					return shield_yellow_c;
				case 'D':
					return shield_yellow_d;
				case 'E':
					return shield_yellow_e;
			}
		}
		return null;
	}
		
	public static Image getKnight(Color color) {
		if(color.equals(Color.RED))
			return knight_red;
		if(color.equals(Color.BLUE))
			return knight_blue;
		if(color.equals(Color.GREEN))
			return knight_green;
		if(color.equals(Color.YELLOW))
			return knight_yellow;
		return null;
	}
	
	public static Image getAddIcon() {
		return add;
	}
	
	public static Image getFullscreenIcon() {
		return fullscreen;
	}
	
	public static Image getSelectionIcon() {
		return selection;
	}
	
	public static Image getTitleIcon() {
		return title;
	}
	
	public static Image getGamePlay(){
		return gamePlay;
	}
	
	public static Image getLandscape(){
		return landscape;
	}
	
	public static Image getInitialPosessions(){
		return initialPosessions;
	}
	
	public static Image getTilesTypePic(){
		return tilesTypePic;
	}
	
	public static Image getPlayingKnightPic(){
		return playingKnightPic;
	}
	
	public static Image getScoringPic(){
		return scoringPic;
	}
	
	public static Image getRegularTurnsPic(){
		return regularTurnsPic;
	}
	
}
